package edu.cuit.avatar;

import java.io.Serializable;

/**
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/7/12 10:46
 */
public class Student implements Serializable {
    private static final long serialVersionUID = 444455811079186887L;

    private int id;

    //静态数据不会被序列化
    private static int nextId = 1;

    private String name;

    private int age;

    //transient:非序列化字段
    private transient String major;

    private String gender;

    private String hobby = "玩游戏";

    public Student(){
        this.id = nextId++;
    }

    public Student(String name, int age, String major, String gender) {
        this();
        this.name = name;
        this.age = age;
        this.major = major;
        this.gender = gender;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getMajor() {
        return major;
    }

    public void setMajor(String major) {
        this.major = major;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public static int getNextId() {
        return nextId;
    }

    public String getHobby() {
        return hobby;
    }

    public void setHobby(String hobby) {
        this.hobby = hobby;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", major='" + major + '\'' +
                ", gender='" + gender + '\'' +
                ", hobby='" + hobby + '\'' +
                '}';
    }
}
